package com.gao.d_routing;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author gao
 * @time 2022/07/05 11:00:31
 */
//@Component
public class Consumer {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, // 创建临时队列
                    exchange = @Exchange(value = "direct_logs", type = ExchangeTypes.DIRECT),
                    key = {"info", "error", "warning"}
            )
    })
    public void receive(String msg) {
        System.out.println("A: " + msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, // 创建临时队列
                    exchange = @Exchange(value = "direct_logs", type = ExchangeTypes.DIRECT),
                    key = {"error"}
            )
    })
    public void receive2(String msg) {
        System.out.println("B: " + msg);
    }
}
